package com.servlet;

import java.io.IOException;

import javax.servlet.http.*;

import com.game.Pokdeng;

@SuppressWarnings("serial")
public class PokdengjaServlet extends HttpServlet {
	Pokdeng match;

	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		resp.setContentType("text/plain");
		String type = req.getParameter("type");
		if (type.equals("start")) {
			match = new Pokdeng("Player");
			match.start();
			resp.getWriter().print(match.getResult());
		} else if (type.equals("draw")) {
			if (!match.game()) {
				match.playerDraw();
			}
			resp.getWriter().print(match.getResult());
		} else if (type.equals("hold")) {
			match.nextTurn();
			resp.getWriter().print(match.getResult());
		} else if (type.equals("restart")) {
			match.start();
			resp.getWriter().print(match.getResult());
		}
	}
}
